﻿using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using LINQtoFxCop.Core;

namespace LINQtoFxCop.Metrics.Types
{
  public class TypeNbFields : MetricsIntrospectionRule
  {
    protected TypeNbFields(string name, string resourceName, Assembly assembly)
      : base(name, resourceName, assembly)
    { }

    public TypeNbFields()
      : base("TypeNbFields")
    { }

    protected override IEnumerable<QueryResult> Query()
    {
      return
        from type in Types
        where type.NbFields() > MetricThreshold()
        select Result(type, type.NbFields());
    }
  }
}
